<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/index.css">
    <script src="./js/index.js" defer></script>
</head>
<body>
    <div class="box">
        <div class="banner">
            <ul class="main">
                <li><img src="./img/banner1.webp" alt=""></li>
                <li><img src="./img/banner2.webp" alt=""></li>
                <li><img src="./img/banner3.webp" alt=""></li>
                <li><img src="./img/banner4.webp" alt=""></li>
            </ul>
        </div>
        <div class="left">
            <ul>
                <li class="leftBtn">&lt;</li>
            </ul>
        </div>
        <div class="right">
            <ul>
                <li class="rightBtn">&gt;</li>
            </ul>
        </div>
        <div class="jumpBtn">
            <ul class="foot">
                <li></li>
                <li></li>
                <li></li>
                <li></li>
            </ul>
        </div>
    </div>

    <script>
        let list = document.querySelectorAll(".foot > li");
        let bannerImg = document.querySelectorAll(".main> li");

        let lastIndex = 0;
        list.forEach(function(item,index){
            item.onclick = function(){
                list[lastIndex].classList.remove("active");
                item.classList.add("active");
                lastIndex = index;

                bannerImg.forEach(function(item, index){
                    bannerImg[index].style.display="none";
                    if(index==lastIndex){
                        bannerImg[lastIndex].style.display="block";
                    }
                })
            }
        });

    </script>
</body>
</html>